package org.example.curriculum_design_6_16.common.base;

/**
 * 基础异常类（所有自定义异常的父类）
 */
public class BaseException extends RuntimeException {
    private final int httpStatus;
    private final String errorCode;
    private final String detail;

    public BaseException(int httpStatus, String errorCode, String message) {
        this(httpStatus, errorCode, message, null);
    }

    public BaseException(int httpStatus, String errorCode, String message, String detail) {
        super(message);
        this.httpStatus = httpStatus;
        this.errorCode = errorCode;
        this.detail = detail;
    }

    // Getters
    public int getHttpStatus() { return httpStatus; }
    public String getErrorCode() { return errorCode; }
    public String getDetail() { return detail; }

    // Fluent API
    public BaseException withDetail(String detail) {
        return new BaseException(this.httpStatus, this.errorCode, this.getMessage(), detail);
    }
}